/*
 * generate by table-builder.Don't modify it
 */
using IQIGame.Onigao.Framework.Serialization;
using IQIGame.Onigao.GamePlay;
using System.Collections.Generic;


namespace CfgTable
{
    public partial class TbCfgHeroStar
    {
        private readonly Dictionary<int, CfgHeroStar> _dataMap;
        private readonly List<CfgHeroStar> _dataList;

        /// <summary>
        /// HeroId 和 Star 联合索引map(key1:HeroId, Key2:Star, value:Id)
        /// </summary>
        public IReadOnlyDictionary<int, IReadOnlyDictionary<int, int>> heroIdStarMap { get; private set; }

        public TbCfgHeroStar(ByteBuf _buf)
        {
            //first read common data
            _TbCommonHeroStar _commonData = null;
            var commonSize = _buf.ReadSize();
            if (commonSize > 0)
            {
                _commonData = new _TbCommonHeroStar(_buf);
            }

            //then read row data
            var size = _buf.ReadSize();
            _dataMap = new Dictionary<int, CfgHeroStar>(size * 3 / 2);
            _dataList = new List<CfgHeroStar>(size);

            for (int i = 0; i < size; i++)
            {
                CfgHeroStar _v;
                _v = CfgHeroStar.DeserializeCfgHeroStar(_buf, _commonData);
                _dataList.Add(_v);
                _dataMap.Add(_v.Id, _v);
            }

            // read extra fields 
            { int __n0 = _buf.ReadSize(); var __f0 = new Dictionary<int, IReadOnlyDictionary<int, int>> (__n0 * 3 / 2); heroIdStarMap = __f0 ; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ) { int __k0; __k0 = _buf.ReadInt(); IReadOnlyDictionary<int, int> __v0; { int __n1 = _buf.ReadSize(); var __f1 = new Dictionary<int, int> (__n1 * 3 / 2); __v0 = __f1 ; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ) { int __k1; __k1 = _buf.ReadInt(); int __v1; __v1 = _buf.ReadInt(); __f1.Add(__k1, __v1); } } __f0.Add(__k0, __v0); } }

            PostInit();
        }

        public IReadOnlyDictionary<int, CfgHeroStar> DataMap => _dataMap;
        public IReadOnlyList<CfgHeroStar> DataList => _dataList;

        public CfgHeroStar Get(int key)
        {
            if (_dataMap.TryGetValue(key, out var v))
            {
                return v;
            }
            IQIGame.Onigao.Framework.LogGame.LogError("[TbCfgHeroStar] config not found,id:" + key.ToString());

            return null;
        }

        public CfgHeroStar GetWithoutError(int key) => _dataMap.TryGetValue(key, out var v) ? v : null;

        /// <summary>
        /// table data file
        /// </summary>
        public static string TableFileName { get; } = "herostar";

        /// <summary>
        /// load table function
        /// </summary>
        public static TbCfgHeroStar LoadFromFunc(System.Func<string, ByteBuf> loadFunc)
        {
            return new TbCfgHeroStar(loadFunc(TableFileName));
        }

        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();

    }

    public partial class CfgHeroStar
    {
        private CfgHeroStar(ByteBuf _buf, _TbCommonHeroStar _commonData)
        {
            Id = _buf.ReadInt();
            HeroId = _buf.ReadInt();
            BigStar = _buf.ReadInt();
            Star = _buf.ReadInt();
            { int dataIndex = _buf.ReadInt() - 1; Cost = _commonData._field0[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; GoldCost = _commonData._field1[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; AttTypes = _commonData._field2[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; AttValues = _commonData._field3[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; DeltaAttrValues = _commonData._field4[dataIndex]; }
            { int dataIndex = _buf.ReadInt() - 1; SkillIdMap = _commonData._field5[dataIndex]; }
            IsShowFeature = _buf.ReadBool();
            SkillName = TableCenter.GetI18NText(_buf.ReadInt());
            SkillEffectText = TableCenter.GetI18NText(_buf.ReadInt());

            PostInit();
        }

        internal static CfgHeroStar DeserializeCfgHeroStar(ByteBuf _buf, _TbCommonHeroStar _commonData)
        {
            return new CfgHeroStar(_buf, _commonData);
        }

        /// <summary>
        /// major key
        /// </summary>
        public int Id { get; private set; }

        /// <summary>
        /// 英雄id
        /// </summary>
        public int HeroId { get; private set; }
        /// <summary>
        /// 大星级(展示)
        /// </summary>
        public int BigStar { get; private set; }
        /// <summary>
        /// 星级
        /// </summary>
        public int Star { get; private set; }
        /// <summary>
        /// 消耗道具的id|数量
        /// </summary>
        public IReadOnlyList<int> Cost { get; private set; }
        /// <summary>
        /// 消耗货币的id|数量
        /// </summary>
        public IReadOnlyList<int> GoldCost { get; private set; }
        /// <summary>
        /// 基础加成-类型
        /// </summary>
        public IReadOnlyList<int> AttTypes { get; private set; }
        /// <summary>
        /// 基础加成-值
        /// </summary>
        public IReadOnlyList<int> AttValues { get; private set; }
        /// <summary>
        /// 等级成长值-值
        /// </summary>
        public IReadOnlyList<int> DeltaAttrValues { get; private set; }
        /// <summary>
        /// 当前星级所持被动技能ID|等级
        /// </summary>
        public IReadOnlyList<int> SkillIdMap { get; private set; }
        /// <summary>
        /// 特性名称
        /// </summary>
        public bool IsShowFeature { get; private set; }
        /// <summary>
        /// 特性名称
        /// </summary>
        public string SkillName { get; private set; }
        /// <summary>
        /// 特性描述文本
        /// </summary>
        public string SkillEffectText { get; private set; }


        /// <summary>
        /// post process table
        /// </summary>
        partial void PostInit();
    }

    /// <summary>
    /// internal common data.Optimize memory
    /// </summary>
    internal class _TbCommonHeroStar
    {

        internal IReadOnlyList<IReadOnlyList<int>> _field0 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field1 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field2 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field3 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field4 { get; private set; }
        internal IReadOnlyList<IReadOnlyList<int>> _field5 { get; private set; }
        internal _TbCommonHeroStar(ByteBuf _buf)
        {
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field0 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field1 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field2 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field3 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field4 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
            { int __n0 = _buf.ReadSize(); var __f0 = new int[__n0][]; _field5 = __f0; for (var __i0 = 0 ; __i0 < __n0 ; __i0++ ){ int[] __v0; { int __n1 = _buf.ReadSize(); var __f1 = new int[__n1]; __v0 = __f1; for (var __i1 = 0 ; __i1 < __n1 ; __i1++ ){ int __v1; __v1 = _buf.ReadInt(); __f1[__i1] = __v1;} } __f0[__i0] = __v0;} }
        }

    }
}
